<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../css/mui.min.css">
		<style>
			html,body {
				background-color: #efeff4;
			}
			header.mui-bar{
				display: none;
			}
			.mui-bar-nav~.mui-content{
				padding: 0;
			}
			.mui-btn{
			  	display: block;
			  	width: 120px;
			  	margin: 10px auto;
			  }
			  #info{
			  	padding: 20px 10px ;
			  }
		</style>
		
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">消息框（dialog）</h1>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded" style="margin: 5px;text-align: center;">
				<button id='alertBtn' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">警告消息框</button>
				<button id='confirmBtn' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">确认消息框</button>
				<button id='promptBtn' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">输入对话框</button>
				<button id='toastBtn' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">自动消失提示框</button>
				<button id='pickDateBtn' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">日期选择框</button>
				<button id='pickTimeBtn' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">时间选择框</button>
				<div id="info">
		
				</div>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/app.js"></script>
		<script>
			mui.init();
		</script>
		<script type="text/javascript" charset="utf-8">
			var info = document.getElementById("info");
			  document.getElementById("alertBtn").addEventListener('tap',function(){
			  	mui.alert('欢迎使用Hello MUI','Hello MUI',function(){
			  		info.innerText = '你刚关闭了警告框';
			  	});
			  });
			  
			  document.getElementById("confirmBtn").addEventListener('tap',function(){
			  	var btnArray = ['是','否'];
			  	mui.confirm('MUI是个好框架，确认？','Hello MUI',btnArray,function(e){
			  		if(e.index==0){
			  			info.innerText = '你刚确认MUI是个好框架';
			  		}else{
			  			info.innerText = 'MUI没有得到你的认可，继续加油'
			  		}
			  	})
			  });
			  
			  //TODO iOS 8.x平台存在bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了，故临时使用click代替tap；
			  document.getElementById("promptBtn").addEventListener('click',function(){
			  	var btnArray = ['确定','取消'];
			  	mui.prompt('请输入你对MUI的评语：','性能好','Hello MUI',btnArray,function(e){
			  		if(e.index==0){
			  			info.innerText = '谢谢你的评语：'+e.value;
			  		}else{
			  			info.innerText = '你点了取消按钮';
			  		}
			  	})
			  });
			  document.getElementById("toastBtn").addEventListener('tap',function(){
			  	mui.toast('欢迎体验Hello MUI');
			  });
			  document.getElementById("pickDateBtn").addEventListener('tap',function () {
			  	var dDate=new Date();
				dDate.setFullYear(2014,7,16);
				var minDate=new Date();
				minDate.setFullYear(2010,0,1);
				var maxDate=new Date();
				maxDate.setFullYear(2016,11,31);
				plus.nativeUI.pickDate( function(e) {
					var d=e.date;
					info.innerText = '您选择的日期是:'+d.getFullYear()+"-"+(d.getMonth()+1)+"-"+ d.getDate();
				},function(e){
					info.innerText = "您没有选择日期";
				},{title:"请选择日期",date:dDate,minDate:minDate,maxDate:maxDate});
			})
			document.getElementById("pickTimeBtn").addEventListener('tap',function () {
				var dTime=new Date();
				dTime.setHours(6,0);
				plus.nativeUI.pickTime(function(e){
					var d=e.date;
					info.innerText = "您选择的时间是："+d.getHours()+":"+d.getMinutes();
				},function (e){
					info.innerText = "您没有选择时间" 
				},{title:"请选择时间",is24Hour:true,time:dTime});
			});
		</script>
	</body>
</html>